package com.itcast.common.model.dto.response;

import com.itcast.common.enums.CheckupReportStatusEnum;
import com.itcast.common.enums.CheckupReportTransactionsStatusEnum;
import com.itcast.common.enums.CheckupStatusEnum;
import com.itcast.common.enums.OrderStatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Atom
 * @create 2024-07-17 11:33
 */
@Data
@Builder
@ApiModel("状态数量汇总统计响应模型")
public class StatusCountSummaryResDTO {
    /**
     * 总数量
     */
    @ApiModelProperty("总数量")
    private Long totalCount;

    /**
     * 所有状态的订单数量列表
     */
    @ApiModelProperty("所有状态的订单数量列表")
    private List<StatusCountResDTO> statusCounts;

    /**
     * 构建订单状态数量统计实例
     *
     * @return 订单状态数量统计实例
     */
    public static StatusCountSummaryResDTO ordersInstance() {
        List<StatusCountResDTO> statusCounts = new ArrayList<>();
        for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
            StatusCountResDTO statusCountResDTO = new StatusCountResDTO(orderStatusEnum.getCode(), 0L);
            statusCounts.add(statusCountResDTO);
        }

        return StatusCountSummaryResDTO.builder()
                .totalCount(0L)
                .statusCounts(statusCounts)
                .build();
    }

    /**
     * 构建体检单状态数量统计实例
     *
     * @return 体检单状态数量统计实例
     */
    public static StatusCountSummaryResDTO checkupFormInstance() {
        List<StatusCountResDTO> statusCounts = new ArrayList<>();
        for (CheckupStatusEnum checkupStatusEnum : CheckupStatusEnum.values()) {
            StatusCountResDTO statusCountResDTO = new StatusCountResDTO(checkupStatusEnum.getCode(), 0L);
            statusCounts.add(statusCountResDTO);
        }

        return StatusCountSummaryResDTO.builder()
                .totalCount(0L)
                .statusCounts(statusCounts)
                .build();
    }

    /**
     * 构建总检单状态数量统计实例
     *
     * @return 总检单状态数量统计实例
     */
    public static StatusCountSummaryResDTO checkupSummaryInstance() {
        List<StatusCountResDTO> statusCounts = new ArrayList<>();

        //总检单只有待总检和已总检两个状态
        statusCounts.add(new StatusCountResDTO(CheckupStatusEnum.AWAITING_FINAL_CHECK.getCode(), 0L));
        statusCounts.add(new StatusCountResDTO(CheckupStatusEnum.COMPLETED.getCode(), 0L));

        return StatusCountSummaryResDTO.builder()
                .totalCount(0L)
                .statusCounts(statusCounts)
                .build();
    }

    /**
     * 构建体检报告状态数量统计实例
     *
     * @return 体检报告状态数量统计实例
     */
    public static StatusCountSummaryResDTO checkupReportInstance() {
        List<StatusCountResDTO> statusCounts = new ArrayList<>();
        for (CheckupReportStatusEnum checkupReportStatusEnum : CheckupReportStatusEnum.values()) {
            StatusCountResDTO statusCountResDTO = new StatusCountResDTO(checkupReportStatusEnum.getCode(), 0L);
            statusCounts.add(statusCountResDTO);
        }

        return StatusCountSummaryResDTO.builder()
                .totalCount(0L)
                .statusCounts(statusCounts)
                .build();
    }

    /**
     * 构建体检报告出入库状态数量统计实例
     *
     * @return 体检报告出入库状态数量统计实例
     */
    public static StatusCountSummaryResDTO checkupReportTransactionsInstance() {
        List<StatusCountResDTO> statusCounts = new ArrayList<>();
        for (CheckupReportTransactionsStatusEnum checkupReportTransactionsStatusEnum : CheckupReportTransactionsStatusEnum.values()) {
            StatusCountResDTO statusCountResDTO = new StatusCountResDTO(checkupReportTransactionsStatusEnum.getCode(), 0L);
            statusCounts.add(statusCountResDTO);
        }

        return StatusCountSummaryResDTO.builder()
                .totalCount(0L)
                .statusCounts(statusCounts)
                .build();
    }
}
